『Haskell Design Patterns』
https://gyazo.com/aa9bad23b2f2b7ed47054fb4aa177697
2015/11/6
166page
1. Functional Patterns – the Building Blocks
Higher-order functions
Functions as first-class citizens
Composing functions
Currying functions
Currying and composability
Decoupling with currying
Recursion
Non-tail recursion
Tail recursion
Folding abstracts recursion
Types, pattern matching and polymorphism
Algebraic types and pattern matching
Recursive types
Polymorphism
Parametric polymorphism
Ad-hoc polymorphism
Alternation-based ad-hoc polymorphism
Class-based ad-hoc polymorphism
Alternation-based versus class-based
Polymorphic dispatch and the visitor pattern
Unifying parametric and ad-hoc polymorphism
Functions, types, and patterns
The Strategy pattern
The Template pattern
The Iterator pattern
Decoupling behavior and modularizing code
Lazy evaluation
Streams
Modeling change with streams
Lazy evil
Monads
Composing monads and structuring programs
Summary
2. Patterns for I/O
I/O as a first class citizen
I/O as a functor, applicative, and monad
Imperative I/O
Lazy I/O
The problems with lazy I/O
Resource management with bracket
Iteratee I/O
Iteratee
Enumerator
Generalized iteratees, enumerators, and enumeratees
Iteratee I/O libraries
Comparing the three styles of I/O
Summary
3. Patterns of Composition
Applicative functor
Monad
Monad as Functor
Monad as Applicative
Sequencing actions with Monad and Applicative
Monads and the bind chain
Composing with Monads
Monad transformers
IO in Monad stacks
Sequence of stack composition
Implementing an Arrow
Arrow operators
Kleisli Arrows and Monad Arrows
Why Arrows?
Summary
4. Patterns of Folding and Traversing
Folding over lists
Folding with monadic functions
Folding with Monoid
Foldable
Mapping over lists
Traversable
A Traversable Tree
The traversal and the Iterator pattern
Modernizing Haskell 98
Lenses
Writing a Lens
Composable getters and setters
Lens Traversal
Lens.Fold
The Lens library
Summary
5. Patterns of Type Abstraction
Abstracting function types: RankNTypes
Abstracting datatypes
Universal quantification
Existential quantification and abstract datatypes
Generalized algebraic datatypes
The Typecase pattern
Dynamic types
Using existentials
Abstracting type-classes
Summary
6. Patterns of Generic Programming
Patterns of generic programming
Patterns 1 and 2 – functions
Pattern 3 – polymorphic types and functions
Pattern 4 – type-class polymorphism
Pattern 5 – meta-programming
Derivable type-classes
Generalized newtype deriving
Pattern 6 – type laws
Pattern 7 – datatype generic programming
The sum of products style
The sum of products type representation
Translating between the type and representation
Writing a datatype-generic function
Adding a new datatype
Tying the recursive knot
Generic map
Generic unfold and fold
Scrap your boilerplate
Type-safe cast with Typeable
Type-safe function application
Shallow traversal and the Data type-class
Typeable and data
Scrap your boilerplate in context
Summary
7. Patterns of Kind Abstraction
Higher-order kinds
Higher-kinded polymorphism
Associated type synonyms
Using functional dependencies
Associated type synonyms
Associated types versus functional dependencies
Type (synonym) families
Data families
Kind polymorphism
The PolyKinds language extension
Type promotion
Promoting types to kinds
Type-level programming
Promoting term-level programs to type-level
Closed type families
The history of type-level programming in Haskell
Type-level and generic programming
Dependently-typed programming
Haskell and dependently-typed programming
Summary
Epilogue
Index